package 第k个数;

import java.util.Scanner;

public class Main {
    static int N = 100010, n, k;
    static int[] q = new int[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        k = in.nextInt();
        for (int i = 0; i < n; i++) {
            q[i] = in.nextInt();
        }
        System.out.println(qsort(0, n - 1, k));
    }

    private static int qsort(int l, int r, int k) {
        if (l >= r) {
            return q[l];
        }
        int i = l - 1, j = r + 1, x = q[l + r >> 1];
        while (i < j) {
            do {
                i++;
            } while (q[i] < x);
            do {
                j--;
            } while (q[j] > x);
            if (i < j) {
                swap(i, j);
            }
        }
        int sl = j - l + 1;
        if (k <= sl) {
            return qsort(l, j, k);
        }
        return qsort(j + 1, r, k - sl);
    }

    private static void swap(int i, int j) {
        int t = q[i];
        q[i] = q[j];
        q[j] = t;
    }
}
